package 力扣日常刷题.木23一月.第20天320;

public class Demo106插入一个字符 {


    public long maximumSubsequenceCount(String text,String patten) {
        long count = 0,count1 = 0,count2 = 0;

        for (char c : text.toCharArray()) {
            count += c== patten.charAt(1)? count1 : 0;
            count1 += c == patten.charAt(0) ? 1 : 0;
            count2 += c == patten.charAt(1) ? 1 : 0;
        }
        return count + Math.max(count1,count2);
    }
}
